#include "CEntranceHttpClient.h"
#include "CControlManage.h"
#include "cmdHandle/CNetConfig.h"
NETWORKSERVICE_BEGIN_NAMESPACE



T_pullFileRtn CEntranceHttpClient::pullFile(struct tRouteData<T_NullData> *send, string fileName, string filePath)
{
	T_pullFileRtn tRtn;
	if(!send || fileName.empty() || filePath.empty()){
		return tRtn;
    }

    string msg;
    MAP_PARAMS headParams;
    headParams["sn"] = send->msg.sn;
    headParams["timestamp"] = to_string(send->msg.timestamp);
    headParams["sendMsgId"] = send->msg.sendMsgId;
    headParams["appKey"] = send->msg.appKey;
    headParams["signature"] = send->msg.signature;
    try{
        // http请求
        msg = CHttpFile::pullFile( send->route.httpClientInfo.method,
                                    send->route.httpClientInfo.url.c_str(),
                                    &headParams,
                                    fileName,
                                    filePath,
                                    send->route.httpClientInfo.conTimeout,
                                    send->route.httpClientInfo.recvTimeout);
    }catch (...){
        qDebug("CHttpClient::httpReq error:url=%s fileName=%s, filePath=%s",send->route.httpClientInfo.url.c_str(),fileName.c_str(),filePath.c_str());
        return tRtn;
    }
    #ifdef HTTP_CLINET_LOG
    qDebug("httpReq:recv %s",msg.c_str());
    #endif
    tRtn.loadJsonString(msg);
    return tRtn;


	return tRtn;
}

NETWORKSERVICE_END_NAMESPACE
